"use strict";

module.exports = function(app, controller){
  if(!controller){
    return;
  }

  const actionRE = /(.*)Action/;
  var dir = controller.dir;
  var action, path;

  if(!dir){
    return;
  }

  for(let fun in controller){
    if(fun.match(actionRE) && typeof controller[fun] === 'function'){

      action = fun.match(actionRE)[1];
      path = '/' + dir + '/' + action;
      console.log('Map Controller:' + path);

      app.get(path, controller[fun]);
    }
  }
};
